package com.ly.blog2Word.controller;

import com.alibaba.fastjson.JSONObject;
import com.ly.blog2Common.core.http.ResponseMessage;
import com.ly.blog2Common.core.page.PageRequest;
import com.ly.blog2Word.dao.model.WordLabel;
import com.ly.blog2Word.service.CommAdminService;
import com.ly.blog2Word.service.WordLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lyMaster
 * @time: 2020/7/17 19:16
 */
@RequestMapping("/label")
@RestController
public class WordLabelController {


    @Autowired
    private WordLabelService wordLabelService;

    @Autowired
    private CommAdminService commAdminService;


    @PostMapping(value="/save")
    public JSONObject save(@RequestBody WordLabel record) {
        return ResponseMessage.ok(wordLabelService.save(record));
    }

    @PostMapping(value="/delete")
    public JSONObject delete(@RequestBody List<WordLabel> records) {
        return ResponseMessage.ok(wordLabelService.delete(records));
    }

    @PostMapping(value="/findPage")
    public JSONObject findPage(@RequestBody PageRequest pageRequest) {
        return ResponseMessage.ok(wordLabelService.findPage(pageRequest));
    }
    @GetMapping(value="/findAll")
    public JSONObject findPage1() {
        return ResponseMessage.ok(wordLabelService.findPage());
    }

    @PostMapping(value="/findLabelList")
    public JSONObject findLabelList(@RequestBody JSONObject idObj) {
            return ResponseMessage.ok(wordLabelService.findLabelList(idObj.getInteger("id")));
    }

}
